package cn.iocoder.yudao.module.erp.controller.admin.common;

import cn.iocoder.yudao.module.erp.dal.mysql.finance.bankstatement.BankStatementMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;

@Component
@Slf4j
public class ResetBankStatementTask {

    @Resource
    private BankStatementMapper erpBankStatementMapper;

    @Scheduled(cron = "0 0 0 * * ?")  // 每天0点执行
    @Transactional
    public void resetDailyPayments() {
        erpBankStatementMapper.resetDailyValues();
        log.info(new Date() + ": 【定时任务】已重置 erp_bank_statement 表的 day_payment 和 daily_expenses 字段值为0");
    }

}
